package io.zhengsh.vvip.leetcode.twopointer;


public class Q238_Move_Zeroes {

    public static void main(String[] args) {

        Q238_Move_Zeroes.Solution q238_move_zeroes = new Q238_Move_Zeroes.Solution();

        int[] nums = {0, 1, 0, 3, 12};
        q238_move_zeroes.moveZeroes(nums);
        System.out.println();

    }

    static class Solution {
        public void moveZeroes(int[] nums) {
            int n = nums.length, left = 0, right = 0;
            while (right < n) {
                if (nums[right] != 0) {
                    swap(nums, left, right);
                    left++;
                }
                right++;
            }

        }

        private void swap(int[] nums, int left, int right) {
            int temp = nums[left];
            nums[left] = nums[right];
            nums[right] = temp;
        }
    }


}
